<template>
  <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
  >
    <van-cell
        v-for="(item,index) in list"
        :id="this.list.at(index).id"
        :key="item"
        v-slot="list"
        :label="this.list.at(index).noticeBody"
        :title="this.list.at(index).noticeTypeNo"
        is-link
        size="large"
        @click="click(list.at(index))"
    >
      <van-tag v-if="this.list.at(index).status==='0'">有同学未读</van-tag>
      <van-tag v-if="this.list.at(index).status==='1'">全部已读</van-tag>
    </van-cell>
  </van-list>
</template>

<script>
import request from "@/util/request.js";

export default {
  data() {
    return {
      list: [],
      loading: false,
      finished: false,
      tagData: "全部读"
    };
  },
  methods: {
    click(slot) {
      sessionStorage.setItem("noticeNo", slot.noticeNo);
      location.replace("/m/1004");
    },
    onLoad() {
      // 异步更新数据
      // setTimeout 仅做示例，真实场景中一般为 ajax 请求
      setTimeout(() => {
        request.get("/notice_main/all").then(res => {
          this.list = res.data.data;
          this.finished = true;
        });
        // 加载状态结束
        this.loading = false;
      }, 10);
    }
  }
};
</script>


<style scoped>

</style>
